package com.sun.showcase.controller.mall;

import com.sun.showcase.biz.mall.service.MemberBillService;
import com.sun.showcase.client.domain.mall.MemberBill;
import com.sun.showcase.client.query.mall.MemberBillQuery;
import com.sun.showcase.pojo.DataGrid;
import com.sun.showcase.pojo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping(value="/mall/memberBill")
public class MemberBillController{
	
	@Autowired
	private MemberBillService memberBillService;
	
	private Result result = new Result();
	/**
	 * 跳转到MemberBill管理页面
	 * 
	 * @return
	 */
	@RequestMapping(value="goMemberBill")
	public String goMemberBill() {
		return "mall/memberBill";
	}
	/**
	 * 跳转到MemberBill新增页面
	 * 
	 * @return
	 */
	@RequestMapping(value="handleMemberBill")
	public String handleMemberBill(@RequestParam(value="id",required=false) Long id , ModelMap map) {
		return "mall/memberBill_rowEdit";
	}

	/**
	 * 跳转到查看desc页面
	 * 
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="showDesc")
	public MemberBill showDesc(MemberBillQuery memberBillQuery) {
		return memberBillService.get(memberBillQuery);
	}

	/**
	 * 获得分页数据表格
	 */
	@ResponseBody
	@RequestMapping(value = "/datagrid")
	public DataGrid datagrid(MemberBillQuery memberBillQuery) {
		return memberBillService.datagrid(memberBillQuery);
	}
	

	/**
	 * 添加一个MemberBill
	 */
	@ResponseBody
	@RequestMapping(value="add")
	public Result add(MemberBillQuery memberBillQuery) {
		memberBillService.add(memberBillQuery);
		result.setSuccess(true);
		result.setMsg("添加成功！");
		return result;
	}

	/**
	 * 编辑MemberBill
	 */
	@ResponseBody
	@RequestMapping(value="edit")
	public Result edit(MemberBillQuery memberBillQuery) {
		memberBillService.update(memberBillQuery);
		result.setSuccess(true);
		result.setMsg("编辑成功！");
		return result;
	}

	/**
	 * 物理删除MemberBill
	 */
	@ResponseBody
	@RequestMapping(value="delete")
	public Result delete(MemberBillQuery memberBillQuery) {
		memberBillService.delete(memberBillQuery.getIds());
		result.setSuccess(true);
		result.setMsg("删除成功！");
		return result;
	}
	
	/**
	 * 逻辑删除MemberBill
	 */
	@ResponseBody
	@RequestMapping(value="deletePt")
	public Result deletePt(MemberBillQuery memberBillQuery) {
		memberBillService.deletePt(memberBillQuery.getIds());
		result.setSuccess(true);
		result.setMsg("删除成功！");
		return result;
	}
	/**
	 * 全部数据MemberBill
	 */
	@ResponseBody
	@RequestMapping(value="listAll")
	public Result listAll(MemberBillQuery memberBillQuery) {
		List<MemberBillQuery> list = memberBillService.listAll(memberBillQuery);
		result.setSuccess(true);
		result.setMsg("成功！");
		result.setData(list);
		return result;
	}
}
